package com.dddd.blog.bloguser.controller;

import com.dddd.blog.blogcommon.pojo.Result;
import com.dddd.blog.blogcommon.utils.ResultUtils;
import com.dddd.blog.bloguser.service.OSSService;
import com.dddd.blog.bloguser.service.impl.OSSServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author 喵星球的大橘
 */
@RestController
@RequestMapping("/oss")
@CrossOrigin
public class OSSController {

    @Autowired
    private OSSService ossService;

    @PostMapping("/upload")
    @ApiOperation(value = "上传")
    public Result uploadFile(@RequestParam("file")MultipartFile file) throws IOException {
        String url = ossService.upload(file);
        return ResultUtils.success(url);
    }

    @RequestMapping("/test")
    public String test(){
        return "test";
    }

}
